<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/7/15
 * Time: 16:57
 */

namespace app\admin\controller;


use app\admin\logic\BusBusinessLogic;
use app\admin\logic\DriverLogic;
use think\facade\Request;

class Driver extends Base
{

    private $driverLogic;

    public function __construct()
    {
        parent::__construct();
        $this->driverLogic = new DriverLogic();
    }

    public function index(){
        $business = $this->driverLogic->busList();
        $this->assign('business', $business);
        return $this->fetch();
    }

    public function ajaxIndex(){
        $tempWhere = Request::post();
        $res = $this->driverLogic->driverList($tempWhere, self::$nowPage);
        return json($res);
    }

    public function add(){
        $act = 'add';
        $driverId = Request::get('id');
        if ($driverId){
            $act = 'edit';
            $driverInfo = $this->driverLogic->driverInfo($driverId);
            $this->assign('info', $driverInfo['data']);
        }
        $business = $this->driverLogic->busList();
        $this->assign('business', $business);
        $this->assign('act', $act);
        return $this->fetch();
    }

    public function handle(){
        $data = Request::request();
        $res = $this->driverLogic->handle($data);
        return json($res);
    }

    //审核列表

    public function stateIndex(){
        $businessLogic = new BusBusinessLogic();
        $businessList = $businessLogic->getAllBusiness();
        $this->assign('business', $businessList['data']);
        return $this->fetch();
    }

    public function state_add(){
        $driverId = Request::param('id');
        $act = 'state';
        if ($driverId){
            $driverInfo = $this->driverLogic->driverInfo($driverId);
            $this->assign('info', $driverInfo['data']);
        }
        $businessLogic = new BusBusinessLogic();
        $businessList = $businessLogic->getAllBusiness();
        $this->assign('business', $businessList['data']);
        $this->assign('act', $act);
        return $this->fetch();
    }

}